import { reqGetCode, reqUserRegister } from '@/api'
const state = {
  code:''
}
const mutations = {
  GETCODE(state,code){
    state.code = code
  }
}
const actions = {
  async getCode({ commit }, phone) {
    let res = await reqGetCode(phone)
    console.log(res)
    if (res.code == 200) {
      commit('GETCODE', res.data)
      return 'success'
    } else {
      return Promise.reject(new Error('faile'))
    }
  },
  async userRegister({commit},user){
    let res= await reqUserRegister(user)
    console.log(res)
    if (res.code !=200) return Promise.reject(new Error('faile'))
    return 'success'
  }
}
const getters = {}
export default {
  state, mutations, actions, getters
}